<?php

namespace app\command;

use app\common\command\BaseCommand;
use libs\JWT;
use think\console\Input;
use think\console\Output;
use think\console\input\Argument;
use think\console\input\Option;

class CreateToken extends BaseCommand
{
    protected function configure()
    {
        $this->setName('createToken')
            ->addOption('test', 't', Option::VALUE_NONE, 'this is a value_none option')
            ->addOption('required', null, Option::VALUE_REQUIRED, 'this is a value_required option')
            ->addOption('optional', null, Option::VALUE_OPTIONAL, 'this is a value_optional option')
            // 必选参数一定要在可选参数之前
            // ->addArgument('required', Argument::REQUIRED, "argument::required")
            ->addArgument('func', Argument::OPTIONAL, "argument::optional", 'test')
            ->setDescription('this is a description');
    }

    protected function execute(Input $input, Output $output)
    {
        $jwt = new JWT();
        $token = $jwt->encode(['member_id' => 2]);
        echo $token;
    }

    public function test()
    {
        echo 'test';
    }
}
